home *** CD-ROM | disk | FTP | other *** search
- Writing code to 'interface' to NAD
- ----------------------------------
-
- Many external programs, such as playlist editors etc, could benefit from being
- able to 'talk' to NAD. This documents outlines the procedures needed to do so.
-
- ------------------------------------------------------------------------------------------
-
- The NAD Main Window
- -------------------
-
- The Main NAD window can be obtained by doing the following(in C)
-
- const TCHAR g_szClassName[] = TEXT("NadMainWindow");
- HWND NadWindow = FindWindow(g_szClassName, NULL);
-
- ------------------------------------------------------------------------------------------
-
- Command ID's
- ------------
-
- #define ID_PLAY 40010
- #define ID_STOP 40011
- #define ID_PAUSE 40012
- #define ID_NEXTTRACK 40013
- #define ID_PREVIOUSTRACK 40014
- #define ID_EXPANDWINDOW 40105 // this causes the NAD window to 'expand'
- // or contract (like pressing the notch)
-
- These messages are send to the main NAD window using the following code:
-
- SendMessage(hWnd, WM_COMMAND, MAKEWPARAM(ID_EXPANDWINDOW, 0), (LPARAM)NULL);
- (you can change the ID_EXPANDWINDOW to any of the above ID_'s...)
-
- ------------------------------------------------------------------------------------------
-
- The NAD Communication System
- ----------------------------
-
- These messages are sent to NAD using a WM_COPYDATA message. You can use this system
- as an 'alternative' to starting a new NAD.EXE with a path to a playlist. Or to start NAD
- playing a certain file from the playlist. NAD uses this system to talk to itself. If you have
- multiple instances turned off.. See below for examples.
-
- #define NCM_RESETPLAYLIST 0
- #define NCM_ADDTOPLAYLIST 1
- #define NCM_PLAYFILE 2
- #define NCM_PLAYITEM 3
- #define NCM_PLAYFROMSTART 4
- #define NCM_SAVEPLAYLIST 5
- #define NCM_SHUFFLE 6
-
-
- Example 1. Resetting the NAD internal playlist:
- -----------------------------------------------
-
- COPYDATASTRUCT cds;
-
- cds.dwData = NCM_RESETPLAYLIST;
- cds.cbData = 0;
- cds.lpData = NULL;
-
- SendMessage(NadWindow, WM_COPYDATA, (WPARAM)NULL, (LPARAM)&cds);
-
- The playlist will now be empty!
-
-
- Example 2. 'Downloading a playlist':
- ------------------------------------
-
- COPYDATASTRUCT cds;
- char Playlist[1000][_MAX_PATH]; // you could fill this will FULL filenames, or use a linked list
- // there is NO limit to the number of files NAD can hold in a playlist except for memory...
-
- int x;
-
- for(x=0; x<1000; x++)
- {
- cds.dwData = NCM_ADDTOPLAYLIST;
- cds.cbData = lstrlen(Playlist[x]); // This MUST be the LENGTH of the filename
- cds.lpData = Playlist[x]; // This is the FILENAME
- sendMessage(NadWindow, WM_COPYDATA, (WPARAM)NULL, (LPARAM)&cds);
- }
-
- The playlist will now be populated with the Item from the array!.
-
-
- Example 3. Telling NAD to play an Item/file.
- --------------------------------------------
-
- 1>
- cds.dwData = NCM_PLAYFROMSTART;
- cds.cbData = 0;
- cds.lpData = NULL;
- SendMessage(NadWindow, WM_COPYDATA, (WPARAM)NULL, (LPARAM)&cds);
- This tells NAD to start playing from the START of the playlist.
-
- 2>
- cds.dwData = NCM_PLAYFILE;
- cds.cbData = strlen("C:\\test.mp3");
- cds.lpData = "C:\\test.mp3";
- SendMessage(NadWindow, WM_COPYDATA, (WPARAM)NULL, (LPARAM)&cds);
- This tells NAD to reset the playlist and start playing 'C:\test.mp3'.
-
- 3>
- cds.dwData = NCM_PLAYITEM;
- cds.cbData = 5;
- cds.lpData = NULL;
- SendMessage(NadWindow, WM_COPYDATA, (WPARAM)NULL, (LPARAM)&cds);
- This tells NAD to play Item number 5 from the playlist... the alternative is:
-
- 4>
- cds.dwData = NCM_PLAYITEM;
- cds.cbData = -1; // NOTE: the -1....
- cds.lpData = "C:\\test.mp3\0\0";// This string ABSOLUTLEY MUST be DOUBLE NULL terminated(\0\0)
- SendMessage(NadWindow, WM_COPYDATA, (WPARAM)NULL, (LPARAM)&cds);
- This tells NAD to search through the playlist for the FIRST occurence of the filename, set it to
- be the CURRENT item and PLAY... the next track will be whatever comes after this file...
-
- ------------------------------------------------------------------------------------------
-
- Other Miscelleneous Messages
- ----------------------------
-
- For those of you who dont know WM_APP is defined in WINDOWS.H as 0x8000(HEX) or 32768(DEC)
- you dont need to define this USUALLY.....
-
- These commands are sent to the NAD window and NAD will RETURN the value. eg:
- DWORD Playtime = SendMessage(NadWindow, WM_GETCURRENTPLAYTIME, 0, 0);
- DWORD Seconds = Playtime/1000; // because its in MS....
-
- #define WM_GETCURRENTPLAYTIME WM_APP + 0x0700 // returns playtime in MS
- #define WM_GETCURRENTFRAME WM_APP + 0x0701 // returns the last decoded frame
- #define WM_GETMAXFRAME WM_APP + 0x0702 // return the ESTIMATED number of frames
- // this is -1 for a URL stream.
- #define WM_GETVOLUME WM_APP + 0x0703 // returns the CURRENT volume Level
- #define WM_SETVOLUME WM_APP + 0x0704 // lParam = the NEW volume
- // VOLUME values are between 0 and 64, setting to more (or less) will have NO effect...
-
- #define WM_SETCURRENTFRAME WM_APP + 0x0705 // lParam = the Frame to jump to
-
- #define WM_GETPLAYSTATUS WM_APP + 0x0706 // returns integer value(see below)
-
-
-
- // these are the return value from WM_SETPLAYSTATUS
- #define STAT_PLAYING 0
- #define STAT_PAUSED 1
- #define STAT_STOPPED 2
-
-